package com.zxl.yunpicture.application.service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import com.zxl.yunpicture.domain.picture.entity.Picture;
import com.zxl.yunpicture.domain.user.entity.User;
import com.zxl.yunpicture.infrastructure.api.aliyunai.model.CreateOutPaintingTaskResponse;
import com.zxl.yunpicture.interfaces.dto.picture.*;
import com.zxl.yunpicture.interfaces.vo.picture.PictureVO;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
* @author 16328
* @description 针对表【picture(图片)】的数据库操作Service
* @createDate 2025-02-04 14:35:03
*/
public interface PictureApplicationService extends IService<Picture> {


    void validPicture(Picture picture);

    /**
     * 上传图片
     *
     * @param inputSource
     * @param pictureUploadRequest
     * @param loginUser
     * @return
     */
    PictureVO uploadPicture(Object inputSource,
                            PictureUploadRequest pictureUploadRequest,
                            User loginUser);

    /**
     * 将查询请求转化为QueryWrapper对象
     *
     * @param pictureQueryRequest
     * @return
     */
    QueryWrapper<Picture> getQueryWrapper(PictureQueryRequest pictureQueryRequest);

    /**
     * 获取图片封装（单条）
     *
     * @param picture
     * @param request
     * @return
     */
    PictureVO getPictureVo(Picture picture, HttpServletRequest request);


    /**
     * 获取图片包装类（分页）
     *
     * @param picturePage
     * @param request
     * @return
     */
    Page<PictureVO> getPictureVOPage(Page<Picture> picturePage, HttpServletRequest request);


    /**
     * 审核图片状态
     *
     * @param pictureReviewRequest
     * @param loginUser
     */
    void doPictureReview(PictureReviewRequest pictureReviewRequest, User loginUser);

    /**
     * 填充图片审核参数
     *
     * @param picture
     * @param loginUser
     */
    void fillReviewParams(Picture picture, User loginUser);

    /**
     * 批量抓取和创建图片
     *
     * @param pictureUploadByBatchRequest
     * @param loginUser
     * @return
     */
    Integer uploadPictureByBatch(PictureUploadByBatchRequest pictureUploadByBatchRequest, User loginUser);

    /**
     * 清理cos中图片
     *
     * @param oldPicture
     */
    void clearPictureFile(Picture oldPicture);

    /**
     * 删除数据库图片
     *
     * @param PictureId
     * @param loginUser
     */
    void deletePicture(Long PictureId, User loginUser);

    /**
     * 校验图片权限
     *
     * @param loginUser
     * @param picture
     */
    void checkPictureAuth(User loginUser, Picture picture);


    /**
     * 编辑图片信息
     *
     * @param picture
     * @param loginUser
     */
    void editPicture(Picture picture, User loginUser);


    /**
     * 根据用户信息获取该用户的全部图片
     *
     * @param userId
     * @return
     */
    List<PictureVO> getPictureListsBySpaceId(long userId);


    /**
     * 根据颜色搜索图片
     *
     * @param spaceId
     * @param picColor
     * @param loginUser
     * @return
     */
    List<PictureVO> searchPictureByColor(Long spaceId, String picColor, User loginUser);


    /**
     * 批量编辑图片
     *
     * @param pictureEditByBatchRequest
     * @param loginUser
     */
    public void editPictureByBatch(PictureEditByBatchRequest pictureEditByBatchRequest, User loginUser);


    /**
     * 校验参数
     */
    void validateBatchEditRequest(PictureEditByBatchRequest pictureEditByBatchRequest, Long spaceId, User loginUser);


    /**
     * 创建扩图任务
     *
     * @param createPictureOutPaintingTaskRequest
     * @param loginUser
     * @return
     */
    CreateOutPaintingTaskResponse createPictureOutPaintingTask(CreatePictureOutPaintingTaskRequest createPictureOutPaintingTaskRequest, User loginUser);

}

